package com.fmdrama.ui;

import javax.swing.JLabel;

/**
 * 状态栏
 */
public class Status extends JLabel {
	private static final long serialVersionUID = 1L;
	
	private String name = "";
	private int total = 0; //首页解析的数据总条数
	private int complete = 0; //已经完成抓取的条数
	private int loopCount = 0; //已经完成轮数
	
	public Status(String name){
		this.name = name;
		setText();
	}
	
	public void reset(){
		total = 0;
		complete = 0;
		loopCount = 0;
	}
	
	public void setText(String text){
		int process = 0;
		if(complete > 0){
			process = (int)Math.floor((double)this.complete/(double)this.total*100); //计算进度百分比
//			System.out.println((double)this.complete/(double)this.total*100);
		}
		super.setText(this.name + " => 进度：" + process + "%   已完成轮数：" + this.loopCount);
	}

	public void setText(){
		setText(null);
	}
	
	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
		this.setText();
	}

	public int getComplete() {
		return complete;
	}

	public void setComplete(int complete) {
		this.complete = complete;
		this.setText();
	}

	public int getLoopCount() {
		return loopCount;
	}

	public void setLoopCount(int loopCount) {
		this.loopCount = loopCount;
		this.setText();
	}
	
	public void loopCountIncr(){
		setLoopCount(this.getLoopCount()+1);
	}
}
